<template>
	<view class="uni-padding-wrap">			
		<view class="list-view">
			<view class="list-item" v-for="(value,index) in list" :key="index">list - {{value}}</view>
		</view>
		<uni-load-more :loadingType="loadingType" :contentText="contentText"></uni-load-more>		
	</view>
</template>
<script>
	import uniLoadMore from '../../components/uni-load-more.vue'
	import service from '../../service.js';
	import myUrl from '../../common/config.js';
	export default {
		data() {
			return {
				//color:"red",
				perSize :10,
				pageSize: 1,
				listCity: myUrl.cityList, // 要登录的url
				title: 'uni-load-more',
				list: [],
				loadingType: 0,
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多数据了"
				}
			}
		},
		onLoad() {
			service.http(this.listCity,"GET",{"pageSize":this.pageSize},this.callBackResponse);
		},		
		onReachBottom() {
			if (this.loadingType !== 0) {
				return;
			}
			this.loadingType = 1;		
			this.pageSize = this.pageSize + 1;
			service.http(this.listCity,"GET",{"pageSize":this.pageSize},this.callBackResponse);
		},
		components: {
			uniLoadMore
		},
		methods:{
			callBackResponse(data){		
				console.log("data.list.length=" + data.list.length + ",perSize=" + this.perSize + ",pageSize=" + this.pageSize + ",loadingType=" + this.loadingType);
				if(data.list.length <= 0){
					this.loadingType = 2;					
					return;
				}				
				let list = [];
				let that = this;
				// console.log(JSON.stringify(data));				
				for(let i=0;i< data.list.length; i++){
					list.push(data.list[i].cityname);
				}				
				this.list = this.list.concat(list);
				this.loadingType = 0;
			}
		}
	}
</script>

<style>
	.uni-padding-wrap{
		width:99%;
	}
	.list-view {
		width: 100%;
		padding:10upx 0;				
	}

	.list-item {
		margin: 20upx 0;
		height: 100upx;
		line-height: 100upx;
		width: 100%;
		border-radius: 10upx;
		border: 1upx solid #eee;
		text-align: center;
		background:#FFF;
	}
</style>
